package com.example.demo.task;

import com.example.demo.aop.HttpRequestAspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author yuwc
 * @description 同步线程
 * @data 2019/5/17 0017下午 3:23
 * EnableScheduling
 */
@Component
public class MyTask {

    /**
     * 注意logger引入类型 引入slf4j包
     */
    private static final Logger log = LoggerFactory.getLogger(HttpRequestAspect.class);

    @Scheduled(cron = "0/5 * * * * *")
    public void scheduled() {
        log.info("=====>>>>>使用cron  {}", System.currentTimeMillis());
    }

    @Scheduled(fixedRate = 5000)
    public void scheduled1() {
        log.info("=====>>>>>使用fixedRate{}", System.currentTimeMillis());
    }

    @Scheduled(fixedDelay = 5000)
    public void scheduled2() {
        log.info("=====>>>>>fixedDelay{}", System.currentTimeMillis());
    }

}
